************************
**# A. Automation IPUMS
************************
use "raw/task_content_bea_1947_1978.dta", clear
keep consolidated_bea task_negative_5yr
rename task_negative_5yr automation
replace automation = -automation

merge 1:m consolidated_bea using "raw/industry_xwalk_census_bea.dta"
keep if _m == 3
drop _m

keep automation ind1990

save "processing/automation_ind1990_1947_1978.dta",replace


**********************
**# B. Automation SIC
**********************
merge 1:m ind1990 using "raw/cw_ind1990_ind1990ddx.dta"
keep if _m == 3
drop _m

gen n = 1
egen totn = total(n), by(ind1990ddx)
gen share = 1/totn

replace automation = automation*share

collapse (sum) automation, by(ind1990ddx)

merge 1:m ind1990ddx using "raw/cw_sic87_ind1990ddx"
keep if _m == 3 & sic >= 2000 & sic < 4000
keep automation sic87
rename sic sic

save "processing/automation_sic_1947_1978.dta", replace
